package com.xju.atpgs.service.Impl;

import com.xju.atpgs.entity.Section;
import com.xju.atpgs.entity.SectionExample;
import com.xju.atpgs.entity.User;
import com.xju.atpgs.mapper.SectionMapper;
import com.xju.atpgs.mapper.UserMapper;
import com.xju.atpgs.service.SectionService;
import com.xju.atpgs.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SectionServiceImpl implements SectionService {

    @Autowired
    private SectionMapper sectionMapper;

    @Override
    public void add(Section section) {
        sectionMapper.insert(section);
    }

    @Override
    public List<Section> findAll() {
        SectionExample sectionExample=new SectionExample();
        sectionExample.createCriteria().andSecIdIsNotNull();
        return sectionMapper.selectByExample(sectionExample);
    }

    @Override
    public Section findByName(String name) {
        SectionExample sectionExample=new SectionExample();
        sectionExample.createCriteria().andSecNameEqualTo(name);
        return sectionMapper.selectByExample(sectionExample).get(0);
    }

    @Override
    public Section findById(String id) {
        return sectionMapper.selectByPrimaryKey(id);
    }
}
